<html>
<head><meta charset="utf-8"><title>whole crate graph LTO? · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/whole.20crate.20graph.20LTO.3F.html">whole crate graph LTO?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="161964051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/whole%20crate%20graph%20LTO%3F/near/161964051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/whole.20crate.20graph.20LTO.3F.html#161964051">(Mar 28 2019 at 15:34)</a>:</h4>
<p>Hey <span class="user-mention" data-user-id="124287">@mw</span> , where can I go to learn more about the whole crate graph LTO that you mentioned in the meeting?</p>



<a name="161964237"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/whole%20crate%20graph%20LTO%3F/near/161964237" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Zoxc <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/whole.20crate.20graph.20LTO.3F.html#161964237">(Mar 28 2019 at 15:35)</a>:</h4>
<p>Isn't that just <code>-C lto=thin</code>? Though <code>C lto=fat</code> would also count I guess</p>



<a name="161964372"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/whole%20crate%20graph%20LTO%3F/near/161964372" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/whole.20crate.20graph.20LTO.3F.html#161964372">(Mar 28 2019 at 15:36)</a>:</h4>
<p>i got the impression from <span class="user-mention" data-user-id="124287">@mw</span> that there were two kinds of thin LTO</p>



<a name="161964552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/whole%20crate%20graph%20LTO%3F/near/161964552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/whole.20crate.20graph.20LTO.3F.html#161964552">(Mar 28 2019 at 15:38)</a>:</h4>
<p>So, there is "local" ThinLTO which does ThinLTO just among the object files of the _current_ crate</p>



<a name="161964600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/whole%20crate%20graph%20LTO%3F/near/161964600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/whole.20crate.20graph.20LTO.3F.html#161964600">(Mar 28 2019 at 15:38)</a>:</h4>
<p>and then there is crate graph ThinLTO which (like "fat" LTO) pulls in the LLVM bitcode of upstream crates too</p>



<a name="161964688"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/whole%20crate%20graph%20LTO%3F/near/161964688" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/whole.20crate.20graph.20LTO.3F.html#161964688">(Mar 28 2019 at 15:39)</a>:</h4>
<p>if you don't specify <code>-C lto</code> and compile with multiple codegen units then local ThinLTO will be used</p>



<a name="161964763"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/whole%20crate%20graph%20LTO%3F/near/161964763" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/whole.20crate.20graph.20LTO.3F.html#161964763">(Mar 28 2019 at 15:40)</a>:</h4>
<p>if you compile with just one CGU, then local ThinLTO makes no sense, so no ThinLTO is performed at all</p>



<a name="161964793"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/whole%20crate%20graph%20LTO%3F/near/161964793" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/whole.20crate.20graph.20LTO.3F.html#161964793">(Mar 28 2019 at 15:40)</a>:</h4>
<p>I think <code>-C lto=thin</code> will get you whole-crate-graph ThinLTO</p>



<a name="161964860"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/whole%20crate%20graph%20LTO%3F/near/161964860" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/whole.20crate.20graph.20LTO.3F.html#161964860">(Mar 28 2019 at 15:41)</a>:</h4>
<blockquote>
<p>I think <code>-C lto=thin</code> will get you whole-crate-graph ThinLTO</p>
</blockquote>
<p>ah!</p>



<a name="161964934"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/whole%20crate%20graph%20LTO%3F/near/161964934" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/whole.20crate.20graph.20LTO.3F.html#161964934">(Mar 28 2019 at 15:42)</a>:</h4>
<p>so there's no way to explicitly encode the behavior that we get by default?</p>



<a name="161964960"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/whole%20crate%20graph%20LTO%3F/near/161964960" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/whole.20crate.20graph.20LTO.3F.html#161964960">(Mar 28 2019 at 15:42)</a>:</h4>
<p>I was doing <code>-C lto=thin</code> thinking that yielded something equivalent to our default when i had multiple codegen units.</p>



<a name="161964969"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/whole%20crate%20graph%20LTO%3F/near/161964969" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/whole.20crate.20graph.20LTO.3F.html#161964969">(Mar 28 2019 at 15:42)</a>:</h4>
<p>but it sounds like you are saying that is false?</p>



<a name="161964998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/whole%20crate%20graph%20LTO%3F/near/161964998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/whole.20crate.20graph.20LTO.3F.html#161964998">(Mar 28 2019 at 15:43)</a>:</h4>
<p>let me go look at my results again</p>



<a name="161965211"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/whole%20crate%20graph%20LTO%3F/near/161965211" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/whole.20crate.20graph.20LTO.3F.html#161965211">(Mar 28 2019 at 15:45)</a>:</h4>
<p>yes, there is no way to force the default behavior via <code>-C lto</code></p>



<a name="161965327"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/whole%20crate%20graph%20LTO%3F/near/161965327" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/whole.20crate.20graph.20LTO.3F.html#161965327">(Mar 28 2019 at 15:46)</a>:</h4>
<p>this is where the decision is made: <a href="https://github.com/rust-lang/rust/blob/237bf3244fffef501cf37d4bda00e1fce3fcfb46/src/librustc/session/mod.rs#L558-L625" target="_blank" title="https://github.com/rust-lang/rust/blob/237bf3244fffef501cf37d4bda00e1fce3fcfb46/src/librustc/session/mod.rs#L558-L625">https://github.com/rust-lang/rust/blob/237bf3244fffef501cf37d4bda00e1fce3fcfb46/src/librustc/session/mod.rs#L558-L625</a></p>



<a name="161965387"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/whole%20crate%20graph%20LTO%3F/near/161965387" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/whole.20crate.20graph.20LTO.3F.html#161965387">(Mar 28 2019 at 15:46)</a>:</h4>
<p><code>-Z thinlto</code> seems to let you force local ThinLTO</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>